package HUZ;

public class demo7 {
    public static void main(String[] args) {
        System.out.println("主线程开始");
        int a=111;
        Thread thread=new Thread(()->{
            System.out.println("自定义线程start");
            try {
                //线程阻塞4秒(保证主线程上的局部变量空间被释放)
                Thread.sleep(4000);
                //此时访问"局部变量a"
                System.out.println("局部变量a的副本:"+a);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("自定义线程start");
        });
        thread.start();

        System.out.println("主线程结束(a空间释放)");
    }
}
